package com.xjoyt.pay.operater.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.operater.auth.interfaces.UserContract;
import com.xjoyt.pay.operater.auth.params.AccountUserParam;
import com.xjoyt.pay.operater.auth.params.UserPageParam;
import com.xjoyt.pay.operater.auth.po.AccountUser;
import com.xjoyt.pay.operater.services.UserService;
import com.xjoyt.pay.params.ChangePasswordParam;
import com.xjoyt.pay.params.LoginParam;

@RestController
@RequestMapping("user")
public class UserController extends AbstractController implements UserContract {

	@Autowired
	private UserService service;

	@Override
	public AccountUser get(@PathVariable("id") String id) {
		return service.get(id);
	}

	@Override
	public PageResult<AccountUser> loadPage(@RequestBody PageParam<UserPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public ExecuteResult<AccountUser> save(@RequestBody AccountUserParam param) {
		return service.save(param);
	}

	@Override
	public ExecuteResult<?> remove(@PathVariable("id") String id) {
		return service.delete(id);
	}

	@Override
	public ExecuteResult<AccountUser> getByAccount(@RequestBody LoginParam param) {
		return service.getByAccount(param);
	}

	@Override
	public ExecuteResult<?> changePassword(@RequestBody ChangePasswordParam param) {
		return service.changePassword(param);
	}
}
